<?php $__env->startSection("content"); ?>
    <body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label">
                    <span class="x-red">*</span>权限名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="username" name="name" required="" lay-verify="required"
                           autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">
                    <span class="x-red">*</span>权限描述
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="L_pass" name="desc" required="" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button  class="layui-btn" lay-filter="add" lay-submit="">
                    增加
                </button>
            </div>
        </form>
    </div>
    <script>
        layui.use(['form','layer','jquery'], function(){
            $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;
            //监听提交
            form.on('submit(add)', function(data){
                //发异步，把数据提交给php
                $.ajax({
                    url:"<?php echo e(url('/admin/permission/add')); ?>",
                    type: 'post',
                    data:data.field,
                    dataType: 'json',
                    success: function (data) {
                        if(data.error ==1){
                            layer.msg(data.info, function(){
                            });
                        }else if(data.error ==0){
                            layer.alert(data.info, {icon: 6},function(){
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);

                                parent.location.reload();
                            });
                        }else{
                            alert(data.errors)
                        }
                    },
                    fail: function (err) {
                        console.log(err)
                    }
                })
                // layer.alert("增加成功", {icon: 6},function () {
                //     // 获得frame索引
                //     var index = parent.layer.getFrameIndex(window.name);
                //     //关闭当前frame
                //     parent.layer.close(index);
                // });
                return false;
            });


        });
    </script>
    </body>
<?php $__env->stopSection(); ?>
<?php echo $__env->make("admin.layout.layout", array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>